package com.hiv.mapper;

import com.hiv.common.param.page.PageQuerySamplingBoxRecordParam;
import com.hiv.mapper.domain.SamplingBoxRecord;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Repository;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

/**
 * 采样数据盒子关系Mapper接口
 * 
 * @author zhanghong
 * @date 2022-09-20
 */
@Mapper
@Repository
public interface SamplingBoxRecordMapper {
    SamplingBoxRecord selectById(Long id);
    List<SamplingBoxRecord> selectList(SamplingBoxRecord samplingBoxRecord);
    int insert(SamplingBoxRecord samplingBoxRecord);
    int batchInsert(List<SamplingBoxRecord> samplingBoxRecordList);
    int update(SamplingBoxRecord samplingBoxRecord);
    int deleteById(Long id);
    int deleteByIds(String[] ids);

    @Select({"<script>",
            "   select count(1) from sampling_box_record",
            "   <where>",
            "       deleted=0",
            "   </where>",
            "</script>"})
    long pageCount(@Param("param") PageQuerySamplingBoxRecordParam param);
    @Select({"<script>",
            "   select * from sampling_box_record",
            "   <where>",
            "       deleted=0",
            "   </where>",
            "   order by create_time desc limit #{limit} offset #{offset}",
            "</script>"})
    List<SamplingBoxRecord> pageQuery(@Param("param") PageQuerySamplingBoxRecordParam param, @Param("limit") int limit, @Param("offset") long offset);

    @Select("select count(1) from sampling_box_record where box_id=#{boxId}")
    Integer countSamplingNum(Long boxId);

    @Select("select * from sampling_box_record where sampling_id=#{samplingId} limit 1")
    SamplingBoxRecord checkIsBind(@Param("samplingId") Long samplingId);

    @Select("select count(1) from sampling_box_record where box_id=#{boxId}")
    Integer countByBoxId(Long boxId);
}
